package com.evolved.automata.experimental.tests;
import java.util.*;
import java.io.*;
import java.util.concurrent.*;

public class SimpleConsoleInterpreter {

	/**
	 * @param args
	 */
	private ConsoleLineInputReader j_Reader;
	private boolean j_RunningP;
	private Thread j_ConsoleThread;
	private LinkedBlockingQueue<Integer> j_ControlQueue;
	
	public SimpleConsoleInterpreter(ConsoleLineInputReader reader)
	{
		j_Reader=reader;
		j_RunningP=false;
	}

	public SimpleConsoleInterpreter()
	{
		j_RunningP=false;
	}
	
	public boolean IsRunning()
	{
		return j_RunningP;
	}
	
	
	
	
	public void Start()
	{
		try
		{
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			j_RunningP=true;
			while (j_Reader.ProcessLine(reader.readLine()))
			{
				
			}
			j_RunningP=false;
		}
		catch (Exception e)
		{
			j_RunningP=false;
			java.io.StringWriter traceText = new java.io.StringWriter();
			java.io.PrintWriter pWriter = new java.io.PrintWriter(traceText,true);
			e.printStackTrace(pWriter);
			pWriter.close();
			throw new RuntimeException(traceText.toString());
		}
	}
	
	public void SetReader(ConsoleLineInputReader reader)
	{
		j_Reader=reader;
	}
}
